<?php

class nUtil {
	public static function json_decode($json, $assoc = true) {
		$json = str_replace(array("\n", "\r"), "", $json);
		$json = preg_replace('/([{,])(\s*)([^"]+?)\s*:/', '$1"$3":', $json);
		return json_decode($json, $assoc);
	}

	public static function json_decode_file($filename, $assoc = true) {
		return self::json_decode(file_get_contents($filename), $assoc);
	}

}